#pragma once

//To access the first bit
#define FIRST_BYTE_MASK						(1|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7)
#define EX_GET_FIRST_BYTE(x)				((x&FIRST_BYTE_MASK))

//To access the second bit
#define SECOND_BYTE_MASK					(1<<8|1<<9|1<<10|1<<11|1<<12|1<<13|1<<14|1<<15)

#define EX_GET_SECOND_BYTE(x)				(x&SECOND_BYTE_MASK)

#define GET_SECOND_AS_FIRST_BYTE(x)			(EX_GET_SECOND_BYTE(x)>>8)
#define TREAT_SECOND_AS_FIRST_BYTE(x)		((x>>8)&FIRST_BYTE_MASK)
#define EX_TREAT_SECOND_AS_FIRST_BYTE(x)	(TREAT_SECOND_AS_FIRST_BYTE(x)&~FIRST_BYTE_ANTI_MASK)

#define TREAT_FIRST_AS_SECOND_BYTE(x)		((x<<8)&SECOND_BYTE_MASK)
#define EX_TREAT_FIRST_AS_SECOND_BYTE(x)	(TREAT_FIRST_AS_SECOND_BYTE(x)&~SECOND_BYTE_ANTI_MASK)


//To access the third bit
#define THIRD_BYTE_MASK						(1<<16|1<<17|1<<18|1<<19|1<<20|1<<21|1<<22|1<<23)

#define EX_GET_THIRD_BYTE(x)				(x&THIRD_BYTE_MASK)

#define GET_THIRD_AS_FIRST_BYTE(x)			(EX_GET_THIRD_BYTE(x)>>16)
#define TREAT_THIRD_AS_FIRST_BYTE(x)		((x>>16)&FIRST_BYTE_MASK)
#define EX_TREAT_THIRD_AS_FIRST_BYTE(x)		(TREAT_THIRD_AS_FIRST_BYTE(x)&~FIRST_BYTE_ANTI_MASK)

#define TREAT_FIRST_AS_THIRD_BYTE(x)		((x<<16)&THIRD_BYTE_MASK)
#define EX_TREAT_FIRST_AS_THIRD_BYTE(x)		(TREAT_FIRST_AS_THIRD_BYTE(x)&~THIRD_BYTE_ANTI_MASK)


//To access the forth bit
#define FOURTH_BYTE_MASK					(1<<24|1<<25|1<<26|1<<27|1<<28|1<<29|1<<30|1<<31)

#define EX_GET_FOURTH_BYTE(x)				(x&FOURTH_BYTE_MASK)

#define GET_FOURTH_AS_FIRST_BYTE(x)			(EX_GET_FOURTH_BYTE(x)>>24)
#define TREAT_FOURTH_AS_FIRST_BYTE(x)		((x>>24)&FIRST_BYTE_MASK)
#define EX_TREAT_FOURTH_AS_FIRST_BYTE(x)	(TREAT_FOURTH_AS_FIRST_BYTE(x)&~FIRST_BYTE_ANTI_MASK)

#define TREAT_FIRST_AS_FOURTH_BYTE(x)		((x<<24)&FOURTH_BYTE_MASK)
#define EX_TREAT_FISRT_AS_FOURTH_BYTE(x)	(TREAT_FIRST_AS_FOURTH_BYTE(x)&~FOURTH_BYTE_ANTI_MASK)



//To access everything but the first bit
#define FIRST_BYTE_ANTI_MASK		(SECOND_BYTE_MASK|THIRD_BYTE_MASK|FOURTH_BYTE_MASK)

//To access everything but the first bit
#define SECOND_BYTE_ANTI_MASK		(FIRST_BYTE_MASK|THIRD_BYTE_MASK|FOURTH_BYTE_MASK)

//To access everything but the first bit
#define THIRD_BYTE_ANTI_MASK		(FIRST_BYTE_MASK|SECOND_BYTE_MASK|FOURTH_BYTE_MASK)

//To access everything but the first bit
#define FOURTH_BYTE_ANTI_MASK		(FIRST_BYTE_MASK|SECOND_BYTE_MASK|THIRD_BYTE_MASK)